/**
 * 水库
 */
var xunStore4r_1 = Ext.create('Ext.data.Store', {
	storeId: 'xunSample4r_1',
	fields:[ 'index1', 'index2', 'index3', 'index4', 'index5', 'index6', 'index7', 'index8', 'index9', 'index10',
		'index11', 'index12', 'index13', 'index14', 'index15', 'index16', 'index17', 'index18', 'index19', 'index20'],
	data: [ {index1:'1月'},
			{index1:'2月'},
			{index1:'3月'},
			{index1:'4月'},
			{index1:'5月'},
			{index1:'6月'},
			{index1:'7月'},
			{index1:'8月'},
			{index1:'9月'},
			{index1:'10月'},
			{index1:'11月'},
			{index1:'12月'},
			{index1:'全年'}],
	listeners: {
		datachanged: {
			fn: function(obj, eOpt){
			//	console.log('need data');
				if(chartSectionSingle1 != null){
					var series = chartSectionSingle1.series;

				//	series[0].setData(getDataArray(obj, 'index2', 0, 12));
				//	series[1].setData(getDataArray(obj, 'index3', 0, 12));
				}
			}
		}
	}
});

var xunChartReservior1;
var xunChartReservior2;

function xunReserviorChart(element, title){
	return Highcharts.chart(element, {
		title: {
	        text: title
	    },
	    xAxis: {
	        categories: ['洪门水库', '廖坊水库']
	    },
	    yAxis: {
	    	title: {
	            text: '蓄变量'
	        }
	    },
	    plotOptions: {
	    	column: {
	    		maxPointWidth: 35
	    	}
	    },
	    legend: {
	    	enabled: false
	    },
	    series: [{
	        type: 'column',
	        name: '供水',
	        data: [0, 0]
	    }]
	});
}

function xunReserviorChart2(element, title){
	return Highcharts.chart(element, {
	    chart: {
	        type: 'area'
	    },
	    title: {
	        text: title
	    },
	    xAxis: {
	        allowDecimals: false,
	        labels: {
	            formatter: function () {
	                return this.value; // clean, unformatted number for year
	            }
	        }
	    },
	    yAxis: {
	        title: {
	            text: '蓄水量'
	        },
	        labels: {
	            formatter: function () {
	                return this.value / 1000 + 'k';
	            }
	        }
	    },
	    /*tooltip: {
	        pointFormat: '{series.name} produced <b>{point.y:,.0f}</b><br/>warheads in {point.x}'
	    },*/
	    plotOptions: {
	        area: {
	            pointStart: 1940,
	            marker: {
	                enabled: false,
	                symbol: 'circle',
	                radius: 2,
	                states: {
	                    hover: {
	                        enabled: true
	                    }
	                }
	            }
	        }
	    },
	    series: [{
	        name: '洪门水库',
	        data: [null, null, null, null, null, 6, 11, 32, 110, 235, 369, 640,
	            1005, 1436, 2063, 3057, 4618, 6444, 9822, 15468, 20434, 24126,
	            27387, 29459, 31056, 31982, 32040, 31233, 29224, 27342, 26662,
	            26956, 27912, 28999, 28965, 27826, 25579, 25722, 24826, 24605,
	            24304, 23464, 23708, 24099, 24357, 24237, 24401, 24344, 23586,
	            22380, 21004, 17287, 14747, 13076, 12555, 12144, 11009, 10950,
	            10871, 10824, 10577, 10527, 10475, 10421, 10358, 10295, 10104]
	    }, {
	        name: '廖坊水库',
	        data: [null, null, null, null, null, null, null, null, null, null,
	            5, 25, 50, 120, 150, 200, 426, 660, 869, 1060, 1605, 2471, 3322,
	            4238, 5221, 6129, 7089, 8339, 9399, 10538, 11643, 13092, 14478,
	            15915, 17385, 19055, 21205, 23044, 25393, 27935, 30062, 32049,
	            33952, 35804, 37431, 39197, 45000, 43000, 41000, 39000, 37000,
	            35000, 33000, 31000, 29000, 27000, 25000, 24000, 23000, 22000,
	            21000, 20000, 19000, 18000, 18000, 17000, 16000]
	    }]
	});
}

function xunFillDataReservior(data){
//	console.log(data);
	xunStore4r_1.setData(data);
}

Ext.define('Admin.view.needwater.xunpack.subpage.reservior',{
	extend:'Ext.panel.Panel',
	xtype:'xunReservior',
	//起别名
	alias:'xunReservior',
	require:[],
	user:[],
	userCLs:'big-100 small-100',
	layout: {
        type: 'vbox',
        align: 'stretch'
    },
	items: [/*{
		xtype:'panel',
		margin: '20 0 0 0',
		layout: {
	        type: 'hbox',
	        align: 'stretch'
	    },
		items: [{
			html: '<div id="chart4-reservior-1" style="width:100%; height:100%;"></div>',
			listeners: {
				resize: {
					fn: function(){
						xunChartReservior1.reflow();
					}
				},
				boxready: {
					fn: function(obj, width, height, eOpts){
						xunChartReservior1 = xunReserviorChart('chart4-reservior-1', '蓄变量');
					}
				}
			},
			flex:1
		},{
			html: '<div id="chart4-reservior-2" style="width:100%; height:100%;"></div>',
			listeners: {
				resize: {
					fn: function(){
						xunChartReservior2.reflow();
					}
				},
				boxready: {
					fn: function(obj, width, height, eOpts){
						xunChartReservior2 = xunReserviorChart2('chart4-reservior-2', '蓄水量变化');
					}
				}
			},
			flex:1
		}],
		flex: 1
	},*/{
		xtype: 'grid',
		store: Ext.data.StoreManager.lookup('xunSample4r_1'),
		margin: '20 0 0 0',
		border: true,
		columns: [
			{ text: '月份', dataIndex: 'index1', minWidth: 100, width:'29%', align: 'center' },
			{ text: '洪门水库蓄变量', dataIndex: 'index2', minWidth: 100, width:'35%', align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.round(value, 3);
					}
			},
			{ text: '廖坊水库蓄变量', dataIndex: 'index3', minWidth: 100, width:'35%', align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.round(value, 3);
					}
			},
		],
		flex: 1
	}]

});
